---
title: CI/CD Integration
sidebar_label: CI/CD Integration
---

DevSpace is designed to work in non-interactive environments the same way it does in interactive environments. To use DevSpace inside a CI/CD pipeline, simply install it as part of your pipeline or start the pipeline with a VM or container image that already contains DevSpace and run any of the DevSpace commands.

## Docker Image
DevSpace provides an official Docker image that [can be found on Docker Hub](https://hub.docker.com/r/devspacesh/devspace). The Dockerfile for this image is [available on GitHub](https://github.com/loft-sh/devspace/blob/main/Dockerfile).

Use this image as shown here:
```bash
docker run devspacesh/devspace devspace [command] [args]
```

#### Example: Get Version
```bash
docker run devspacesh/devspace devspace --version
```

#### Example: Deployment
```bash
docker run -v ${PWD}:/project -w /project devspacesh/devspace devspace deploy
```
1. Mounts current working directory into `/project` within the container
2. Sets `/project` as working dir
3. Runs `devspace deploy` inside working dir

#### Example: Start Interactive Terminal Session
```bash
docker run -it -v ${PWD}:/project -w /project devspacesh/devspace
```

<br/>


## Deployment Tips

### Avoid Pickers
If you want to run commands such as `devspace enter`, make sure you specify a label selector using `-l`, a container using `-c` etc. to make sure DevSpace can find the right pod/container without having to ask you to select one (which would lead to your pipeline getting stuck).

### `--wait` Flag
DevSpace is configured to deploy and terminate when you run `devspace deploy`. In CI/CD pipelines, it is common to wait until the deployment is actually up and running before continuing the pipeline. You can achieve this by using `--wait`:
```bash
devspace deploy --wait --timeout=120
```
The above command will wait until the desired number of pods is created for all ReplicaSets and until none of the pods are failing anymore. If this is not achieved within the number of seconds specified in `--timeout`, DevSpace will exit with a fatal error.

### Define Profiles
It is often useful to [define profiles in `devspace.yaml`](../configuration/profiles/basics.mdx) for staging, review or production deployments using CI/CD. You can deploy a project using such a profile using the `-p / --profile` flag:
```bash
devspace deploy -p production
```

### Separate Build & Deploy
DevSpace allows you to split up the build and deployment process into two separate commands:
```bash
devspace build                  # Build, tag and push images
devspace deploy --skip-build    # Deploy project without rebuilding images
```

### Run Tests
To run unit or integration tests in your CI/CD pipeline, you have multiple options:
- [Split up build and deployment command](#separate-build--deploy) and run tests before after or in between the commands
- [Define hooks](../configuration/hooks/basics.mdx) that execute commands before/after certain image builds or deployments

<br/>
